import requests
import bs4


def main():
    res = open_url("https://movie.douban.com/top250")
    for n in range(10):
        res = open_url("https://movie.douban.com/top250?start=" + str(n * 25) + "&filter=")
        find_movies(res)
        


def find_movies(res):
    soup = bs4.BeautifulSoup(res.text, "html.parser")
    targets = soup.find_all("div", class_="hd")
    for each in targets:
        print(each.a.span.text)


def open_url(url):
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
    }
    res = requests.get(url, headers=headers)
    return res

if __name__ == '__main__':
    main()
